package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SystemDictionaryItem;
import cn.wolfcode.crm.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//使用IOC的注解告诉SPring来帮我们管理当前对象
@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {
    @Autowired//自动注入
    private SystemDictionaryItemMapper mapper;
    @Override
    public void save(SystemDictionaryItem systemDictionaryItem) {
        mapper.save(systemDictionaryItem);
    }

    @Override
    public void delete(Long id) {
        mapper.delete(id);
    }

    @Override
    public void update(SystemDictionaryItem systemDictionaryItem) {
        mapper.update(systemDictionaryItem);
    }

    @Override
    public SystemDictionaryItem get(Long id) {
        return mapper.get(id);
    }

    @Override
    public List<SystemDictionaryItem> listAll() {
        return mapper.listAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        //封装用户需要的数据
        int count = mapper.selectForCount(qo);
        List<SystemDictionaryItem> list = mapper.selectForList(qo);

        //将用户需要的所有的数据封装起来
        return new PageResult(list,count,qo.getCurrentPage(),qo.getPageSize());
    }

    public List<SystemDictionaryItem> listByDicSn(String sn) {
        return mapper.selectByDicSn(sn);
    }


}
